package day10.RandomAccessFileTest;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

public class Test1 {
    public static void main(String[] args) throws IOException {
        /*
        如果文件不存在，会自动新建文件
        如果文件夹不存在，会出现异常
         */
        RandomAccessFile raf = new RandomAccessFile("/Users/hao/Desktop/abc/f2", "rw");
        raf.write(97); // 00 00 00 61 --> 61
        raf.write(98); // 00 00 00 62 --> 62
        raf.write(99); // 00 00 00 63 --> 63
        raf.write(356);// 00 00 01 64 --> 64

        byte[] a = {
                101,102,103,104,105,
                106,107,108,109,110
        };
        raf.write(a);
        raf.write(a, 2, 4); // 从下标开始的第四个
        raf.close(); // 释放系统资源




    }
}
